###############################################################################
# SuperLinks                                                                  #
# Copyright (c) 2000-2007 Greg Nolle (http://greg.nolle.co.uk)                #
###############################################################################
# This program is free software; you can redistribute it and/or modify it     #
# under the terms of the GNU General Public License as published by the Free  #
# Software Foundation; either version 2 of the License, or (at your option)   #
# any later version.                                                          #
#                                                                             #
# This program is distributed in the hope that it will be useful, but WITHOUT #
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or       #
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for   #
# more details.                                                               ##                                                                             #
# You should have received a copy of the GNU General Public License along     #
# with this program; if not, write to the Free Software Foundation, Inc.,     #
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.                 #
###############################################################################
# ControlPanel/Output/ModifyTemplate.pm.pl -> ModifyTemplate module           #
###############################################################################
# DON'T EDIT BELOW UNLESS YOU KNOW WHAT YOU'RE DOING!                         #
###############################################################################
package Skin::CP::ModifyTemplate;

BEGIN { require "System.pm.pl"; import System qw($SYSTEM); }
BEGIN { require "General.pm.pl"; import General qw($GENERAL); }
require "Standard.pm.pl";

use HTML::Dialog;
use strict;

sub new {
  my ($class) = @_;
  my $self    = {};
  return bless ($self, $class);
}

sub DESTROY { }

###############################################################################
# show subroutine
sub show {
  my $self = shift;
  my %in = (input => undef, error => "", @_);

  #----------------------------------------------------------------------#
  # Printing page...                                                     #

  my $Dialog = HTML::Dialog->new();
  my $Form   = HTML::Form->new();

  my $Body = $Dialog->TableRow(items => [{ body => "$SL::QUERY{'Template'}:", colspan => 2 }]);
  
  my $Template = $Form->TextArea(
    name  => "FORM_TEMPLATE",
    value => $in{'input'}->{'TEMPLATE'},
    rows  => 20
  );
  
  $Body .= $Dialog->TableRow(items => [{ body => $Template, colspan => 2 }]);

  $Body .= $Dialog->FormButton(
    items => [
      { type => "submit", value => "Modify" },
      { type => "reset", value => "Cancel" }
    ], join => "&nbsp;"
  );

  $Body = $Dialog->Table(body => $Body);
  $Body = $Dialog->StandardPage(
    body        => $Body,
    header      => "Modify a Template",
    form        => 1,
    hiddens     => [
      { name => "Referer", value => $SL::QUERY{'Referer'} },
      { name => "TID", value => $in{'input'}->{'TEMPLATESET'}->{'ID'} },
      { name => "Template", value => $SL::QUERY{'Template'} },
      { name => "action", value => "DoModifyTemplate" },
      { name => "CP", value => "1" },
      { name => "SID", value => $SL::ADMIN{'SID'} }
    ]
  );
}

###############################################################################
# do subroutine
sub do {
  my $self = shift;
  my %in = (input => undef, @_);

  #----------------------------------------------------------------------#
  # Printing page...                                                     #

  my $Dialog = HTML::Dialog->new();

  return $Dialog->StandardPage(
    body    => qq~The template has been updated.<p>Click <a href="$SYSTEM->{'SCRIPT_URL'}?CP=1&action=Templates&TID=$in{'input'}->{'TEMPLATESET'}->{'ID'}&SID=$SL::ADMIN{'SID'}">here</a> if you're not redirected in 5 seconds.~,
    header  => "Modify a Template",
    metas   => [
      { http_equiv => "refresh", content => "5; url=$SYSTEM->{'SCRIPT_URL'}?CP=1&action=Templates&TID=$in{'input'}->{'TEMPLATESET'}->{'ID'}&SID=$SL::ADMIN{'SID'}" }
    ]
  );
}

1;